-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Command to provide information for OCaml syntax #1706
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's much better !
Now is probably a good time to decide which features we actually want to document.
There are two possibilities here:
- If the feature is aimed at complete beginner, it might make sense to document as much of the syntax as we can.
- Or we just want to shed a light on weird / rarely use OCaml features that might puzzle even seasoned developers.
@trefis, @pitag-ha, what's your feeling about this ?
It might also depend on how the feature is used: is it called on every on-hover in LSP ? Or only on specific code actions ?
@PizieDust we discussed with trefis and Sonja and for the scope of the feature we think you can first focus on "language extensions". These are advanced features that were added to OCaml other the time and are often not well known by beginners. You can find the list of these features here: About the UI, we can start (after the backend part in Merlin is done) by extending |
Amazing. I should be moving this PR from draft soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a (very incomplete) round of review: could you reformat the file (I provided the result of ocamlformating it in a comment), and refactor / promote the result of the tests so that they can be used to understand the expected behavior ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super cool, @PizieDust , thanks a lot!
Are you planning to add an mli-file for syntax_doc.ml
once you won't change that file that much anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, you're making good progress on this :-)
I made a few comments, and you should also try to sort out the rebase mess :-)
tests/test-dirs/syntax-document/language-extensions.t/first-class-modules.ml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think we just need to improve the locally abstract data types
case before merging a first version of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PR is almost ready.
I just made a few formatting remarks.
Do you want to rebase and squash your changes into meaningful commits ?
If not I can simply squash everything before merging.
* add new command boilerplate * add identifier to syntax_doc definition * update query json to use new identifier * include new return types for query protocol * update test to check type variant declarations * syntax documentation boiler plate * poc implementation for syntax_doc command * update the test description * remove optional identifier and obsolete code * remove optional identifier * add new variant examples * handle type declarations * remove redundant parent_node matching * remove comments * Bump version for release 4.13 * delete intial testing file * add custom documentation * add language extension tests * refined node matching for better docs * add more tests * remove invalid_identifier ouput * ocamlformat, limit lines to 80 chars * add mli for syntax_doc * proper naming * update docs, move type to query_protocol, leave as record * add info type for syntax_docment command json * update to record for json output * change from string output to json * delete redundant test files * delete tests files * move tests code here and promote * remove typedtree nodes * change variable name to a more informative name * Make syntax_doc_result optional * remove redundant cases * use singular and more shorter names * dune promote name changes * lint * url builder function for syntax documentation url * lint * dune promote correct urls * concat urls before returning to query_json * make command return record option * delete test file * correct formatting to original * refactor to be more meaningful * use versbose names * test: start making more precise tests * Apply suggestions from code review Co-authored-by: Ulysse <[email protected]> * Edit descriptions to be less verbose * dune promote description changes * use syn_doc alias * merge duplicate case results * lint * reduce verboseness in test * add eof * Update src/frontend/ocamlmerlin/new/new_commands.ml Co-authored-by: Ulysse <[email protected]> * cover more test * update some match cases * remove trailing whitespaces * use plural form * refactor private and public types for same nodes into one match case * lint and seperate abstract types for public and private * better targeting first class modules * more test for first class modules and capitalization corrections * pass location position to syntaxdoc logic * use cursor position to better target locally abstract datatypes * test case where locally abstract dt shouldnt be triggered * test for first class module where it shouldnt be triggered * use 3rd person singular * add changelog * fix indentation * remove excess whitespace * proper heading --------- Co-authored-by: Ulysse Gérard <[email protected]> Co-authored-by: Ulysse <[email protected]>
CHANGES: Thu Feb 22 14:00:42 CET 2024 + merlin binary - Add a "heap_mbytes" field to Merlin server responses to report heap usage (ocaml/merlin#1717) - Add cache stats to telemetry (ocaml/merlin#1711) - Add new SyntaxDocument command to find information about the node under the cursor (ocaml/merlin#1706) - Fix `FLG -pp ppx.exe -as-pp/-dump-ast` use of invalid shell redirection when direct process launch on Windows. (ocaml/merlin#1723, fixes ocaml/merlin#1722) - Add a query_num field to the `ocamlmerlin` responses to detect server crashes (ocaml/merlin#1716) - Jump to cases within a match statement (ocaml/merlin#1726) - Jump to `module-type` (ocaml/merlin#1728, partially fixes ocaml/merlin#1656) - Exposes stable functions for configuration handling and pattern variable destruction. (ocaml/merlin#1730) + editor modes - vim: load merlin under the ocamlinterface and ocamllex filetypes (ocaml/merlin#1340) - Fix merlinpp not using binary file open (ocaml/merlin#1725, fixes ocaml/merlin#1724)
CHANGES: Thu Feb 22 14:00:42 CET 2024 + merlin binary - Add a "heap_mbytes" field to Merlin server responses to report heap usage (ocaml/merlin#1717) - Add cache stats to telemetry (ocaml/merlin#1711) - Add new SyntaxDocument command to find information about the node under the cursor (ocaml/merlin#1706) - Fix `FLG -pp ppx.exe -as-pp/-dump-ast` use of invalid shell redirection when direct process launch on Windows. (ocaml/merlin#1723, fixes ocaml/merlin#1722) - Add a query_num field to the `ocamlmerlin` responses to detect server crashes (ocaml/merlin#1716) - Jump to cases within a match statement (ocaml/merlin#1726) - Jump to `module-type` (ocaml/merlin#1728, partially fixes ocaml/merlin#1656) - Exposes stable functions for configuration handling and pattern variable destruction. (ocaml/merlin#1730) + editor modes - vim: load merlin under the ocamlinterface and ocamllex filetypes (ocaml/merlin#1340) - Fix merlinpp not using binary file open (ocaml/merlin#1725, fixes ocaml/merlin#1724)
CHANGES: Thu Feb 22 14:00:42 CET 2024 + merlin binary - Add a "heap_mbytes" field to Merlin server responses to report heap usage (ocaml/merlin#1717) - Add cache stats to telemetry (ocaml/merlin#1711) - Add new SyntaxDocument command to find information about the node under the cursor (ocaml/merlin#1706) - Fix `FLG -pp ppx.exe -as-pp/-dump-ast` use of invalid shell redirection when direct process launch on Windows. (ocaml/merlin#1723, fixes ocaml/merlin#1722) - Add a query_num field to the `ocamlmerlin` responses to detect server crashes (ocaml/merlin#1716) - Jump to cases within a match statement (ocaml/merlin#1726) - Jump to `module-type` (ocaml/merlin#1728, partially fixes ocaml/merlin#1656) - Exposes stable functions for configuration handling and pattern variable destruction. (ocaml/merlin#1730) + editor modes - vim: load merlin under the ocamlinterface and ocamllex filetypes (ocaml/merlin#1340) - Fix merlinpp not using binary file open (ocaml/merlin#1725, fixes ocaml/merlin#1724)
CHANGES: Thu Feb 22 14:00:42 CET 2024 + merlin binary - Add a "heap_mbytes" field to Merlin server responses to report heap usage (ocaml/merlin#1717) - Add cache stats to telemetry (ocaml/merlin#1711) - Add new SyntaxDocument command to find information about the node under the cursor (ocaml/merlin#1706) - Fix `FLG -pp ppx.exe -as-pp/-dump-ast` use of invalid shell redirection when direct process launch on Windows. (ocaml/merlin#1723, fixes ocaml/merlin#1722) - Add a query_num field to the `ocamlmerlin` responses to detect server crashes (ocaml/merlin#1716) - Jump to cases within a match statement (ocaml/merlin#1726) - Jump to `module-type` (ocaml/merlin#1728, partially fixes ocaml/merlin#1656) - Exposes stable functions for configuration handling and pattern variable destruction. (ocaml/merlin#1730) + editor modes - vim: load merlin under the ocamlinterface and ocamllex filetypes (ocaml/merlin#1340) - Fix merlinpp not using binary file open (ocaml/merlin#1725, fixes ocaml/merlin#1724)
closes #1692
FEATURE: New Merlin Command - Syntax Document
Introduction
The
Document
command of Merlin returns comments written in code. This PR introduces a new command, theSyntax Document
command which takes the syntax under the cursor, analyses it's TypedTree nodes and returns specific documentation for the Syntax.Code Example
Code
Output
This command can also identify specific
Code
Output
Scope
This command for a start covers
Language Extensions
of OCaml. The covered sections include:More sections will be covered and updated to the command along with other parts of the OCaml programming language.
cc @voodoos @pitag-ha